var t = require("../../../../../../@babel/runtime/helpers/objectSpread2"), e = require("../../../../../../@babel/runtime/helpers/defineProperty"), a = getApp();

Component({
    properties: {
        keywork: {
            type: null
        },
        memberId: {
            type: null
        }
    },
    data: {
        active: 0,
        getHistoryUrl: "plugin.customer-center.frontend.controllers.customer.get-history",
        getTimeUrl: "plugin.customer-center.frontend.controllers.customer.history",
        getConfig: {
            client: "work",
            type: 17
        },
        times: [],
        history: [],
        timeIndex: ""
    },
    lifetimes: {
        attached: function() {
            var t = wx.getStorageSync("langIndex");
            this.setData({
                language: t.en
            }), this.getTimeList();
        }
    },
    methods: {
        getTimeList: function() {
            var t = this, e = {};
            "customer" == this.data.keywork && (this.data.getTimeUrl = "plugin.customer-center.frontend.controllers.customer.history", 
            e.member_id = this.data.memberId);
            var s = a.getNetAddresss(this.data.getTimeUrl);
            a._postNetWork({
                url: s,
                data: e,
                success: function(e) {
                    var a = e.data;
                    1 == a.result ? a.data.time_data.length > 0 && (a.data.time_data.forEach(function(e) {
                        t.data.times.push({
                            time: e,
                            list: [],
                            load: {
                                page: 1,
                                finished: !1
                            },
                            isShow: !1
                        });
                    }), t.setData({
                        times: t.data.times
                    })) : wx.showToast({
                        icon: "none",
                        title: a.msg,
                        duration: 1500
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        },
        closeHistorys: function(t) {
            var a = t.currentTarget.dataset.index, s = this.data.times[a];
            s.isShow = !s.isShow, s.load.finished = !1, this.setData(e({
                timeIndex: a
            }, "times[" + a + "]", s));
        },
        showHistorys: function(t) {
            console.log(t);
            var a = t.currentTarget.dataset.index, s = this.data.times[a];
            s.isShow = !s.isShow, this.setData(e({
                timeIndex: a
            }, "times[" + a + "]", s)), console.log(s), s.isShow && this.getHistory();
        },
        copyMethod: function(t) {
            var e = t.currentTarget.dataset.url;
            wx.redirectTo({
                url: "/" + e,
                fail: function(t) {
                    wx.setClipboardData({
                        data: e,
                        success: function() {
                            wx.hideToast(), wx.showModal({
                                content: "复制成功",
                                showCancel: !1
                            });
                        }
                    });
                }
            });
        },
        getHistory: function(s) {
            var i = this;
            s && this.data.times[s.currentTarget.dataset.ind] && this.data.times[s.currentTarget.dataset.ind].isShow && this.setData({
                timeIndex: s.currentTarget.dataset.ind
            });
            var o = this.data.times[this.data.timeIndex];
            if (o.load.finished) a.tips("没用更多了"); else {
                var r = {
                    page: o.load.page,
                    get_time: o.time
                }, n = {};
                "customer" == this.data.keywork && (this.getHistoryUrl = "plugin.customer-center.frontend.controllers.customer.get-history", 
                r.member_id = this.data.memberId, n = t({}, r));
                var d = a.getNetAddresss(this.data.getHistoryUrl);
                a._postNetWork({
                    url: d,
                    data: n,
                    success: function(t) {
                        var a = t.data;
                        1 == a.result ? ((o.load.page >= a.data.last_page || a.data.data.length < a.data.per_page) && (o.load.finished = !0), 
                        o.list = o.load.page > 1 ? o.list.concat(a.data.data) : a.data.data, o.load.page = ++o.load.page, 
                        i.setData(e({}, "times[" + i.data.timeIndex + "]", o)), console.log(i.data.times)) : wx.showToast({
                            icon: "none",
                            title: a.msg,
                            duration: 1500
                        });
                    },
                    fail: function(t) {
                        console.log(t);
                    }
                });
            }
        }
    }
});